package com.example.fragmentdemo.bean;

import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;

/**
 * Parcelable和Serializable接口都是实现序列化和反序列化的接口,
 * 相比Serializable,Parcelable接口需要自己手动实现,效率更好，
 * 生成的序列化数据较小,效率更加高效,占用的内存比较少。
 */
//为什么要实现序列化,可以直接通过对象实现吗 区别
public class FileBean implements Parcelable {

    private String id;
    private String name;

    private String title;
    private String path;
    private String createTime;
    private String updateTime;
    private int icon;
    private String time;

    private String length;

    private String fileType;

    public FileBean(String name, String title, String path, String createTime, String updateTime, int icon, String time) {
        this.name = name;
        this.title = title;
        this.path = path;
        this.createTime = createTime;
        this.updateTime = updateTime;
        this.icon = icon;
        this.time = time;
    }

    public FileBean() {
    }

    public FileBean(Parcel in) {
        name = in.readString();
        title = in.readString();
        path = in.readString();
        createTime = in.readString();
        updateTime = in.readString();
        icon = in.readInt();
        time = in.readString();
        length = in.readString();
        fileType=in.readString();
        id=in.readString();
    }

    public static final Creator<FileBean> CREATOR = new Creator<FileBean>() {
        @Override
        public FileBean createFromParcel(Parcel in) {
            return new FileBean(in);
        }

        @Override
        public FileBean[] newArray(int size) {
            return new FileBean[size];
        }
    };

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(String updateTime) {
        this.updateTime = updateTime;
    }

    public int getIcon() {
        return icon;
    }

    public void setIcon(int icon) {
        this.icon = icon;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeString(name);
        dest.writeString(title);
        dest.writeString(path);
        dest.writeString(createTime);
        dest.writeString(updateTime);
        dest.writeInt(icon);
        dest.writeString(time);
        dest.writeString(length);
        dest.writeString(fileType);
        dest.writeString(id);
    }

    public String getFileType() {
        return fileType;
    }

    public void setFileType(String fileType) {
        this.fileType = fileType;
    }

    public String getLength() {
        return length;
    }

    public void setLength(String length) {
        this.length = length;
    }

    // 实现 Parcelable 接口必须实现的两个方法

}
